<?php

class Y
{
	private $className;

	public function __construct() 
	{
		$this->path = __FILE__;
		$this->dir = dirname($this->path);
		$this->fileName = basename($this->path);
		$this->className = __CLASS__;
    }

	public function __get($private)
	{
		if($this->$private)
		{
			return $this->$private;

		}else{
			$require = $this->dir.'/class/'.$private.'.class.php';
			if(file_exists($require))
			{
				$classname = ucwords($private);
				require_once $require;
				return new $classname;
			}else{
				die('Erro：你访问的对象不存在！');
			}
		}
	}

	public function getClass()
	{
		$this->className = NULL;
	}

	function __call($methodName, $p) //使用__call尝试调用一个不存在/不可用的成员方法
    {
		die('Erro：你访问的方法不存在！');
    }
}

$_ = new Y;

?>